<template>
  <div style="text-align:center;width:100%;margin:0 auto;height:93px;padding-top:18px;background:#979fa7">
    <div style="float:left"><img :src="logo"></div>
    <div>
      <h1>
        <font>联合重卡IT综合下载平台</font>
      </h1>
    </div>
  </div>
   <div class="role-container">
    <div class="role-tree-left flex-col">
      <div class="title"><i class="el-icon-user"></i>下载导航</div>
      <el-scrollbar class="el-role-list">
        <el-tree
          :data="tree"
          @node-click="nodeClick"
          :default-expand-all="true"
          node-key="id"
          :default-expanded-keys="openKeys"
          :expand-on-click-node="true"
          style="padding: 5px 0; margin-right: 2px"
        >
          <template #default="{ data }">
            <div class="action-group">
              <div class="action-text">
                {{ data.value }}
              </div>
            </div>
          </template>
        </el-tree>
      </el-scrollbar>
    </div>
    <div class="role-tree-right flex-col">
      <div class="title">
        <div><i class="el-icon-folder-opened"></i>下载分类</div>
       
      </div>
      <el-scrollbar class="el-role-list">
          
          <div style="text-align:center;width:100%;margin:0 auto;height:60px;padding-top:18px;">
              <el-form :inline="true" :model="formInline" class="demo-form-inline">
                <el-form-item label="标题/内容">
                  <el-input v-model="formInline.title"></el-input>
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" @click="onSubmit">查询</el-button>
                </el-form-item>
              </el-form>
            </div>
         <vol-table :ck="false" ref="tableList" @rowClick="rowClick" :loadKey="true" :columns="columns" :pagination-hide="false" :height="450" :defaultLoadPage="true" @loadBefore="loadBefore" @loadAfter="loadTableAfter" :endEditAfter="endEditAfter" url="/api/Ok3w_Article/getPageData" :row-index="true"  :index="true" click-edit="false" ></vol-table>

        <look_downfile ref="look_downfile"></look_downfile>
          <el-row :gutter="20" v-for="(x,i) in Math.ceil(fl_types.length/lcout)" :key="x" justify="center">
            <el-col :span="8" v-for="(y,j) in lcout" :key="y">
            <el-card class="box-card" v-if="fl_types[i*lcout+j]!=null">
              <div class="grid-content bg-purple">
                #{{i*lcout+j}}.{{fl_types[i*lcout+j].text}}
              </div>
              <div style="height:120px;overflow-y:auto;">
              <table border="0" cellspacing="0" cellpadding="0">
                <tr v-for="(row, index) in list" :key="index">
                  <td @click=open_info(row.q) v-if="fl_types[i*lcout+j].text===row.sortName"><el-link type="warning">.{{ row.q.title }}.</el-link></td>
                </tr>
              </table>
              </div>
            </el-card>
          </el-col>
        </el-row>
      </el-scrollbar>
    </div>
  </div>

 
</template>
<script>

import { ref, onMounted, onUnmounted } from 'vue';
import http from "@/../src/api/http.js";
var imgUrl = require("@/assets/imgs/comlog.png");
import VolHeader from "@/components/basic/VolHeader.vue";
import VolTable from "@/components/basic/VolTable.vue";
import look_downfile from "@/views/JRdownfile/look_downfile.vue"
export default {
  components: { VolHeader, VolTable, look_downfile, http },
  data() {
    return {
      //注意:数据源中必须有id与parentId字段
      //*树形tree需要注意Id与parentId循环依赖的问题 */
      tree_source :[
        { name: 'tree1', id: 1, parentId: 0 },
        { name: 'tree2', id: 2, parentId: 0 },
        { name: 'tree3', id: 3, parentId: 1 },
        { name: 'tree4', id: 4, parentId: 1 },
        { name: 'tree5', id: 5, parentId: 7 },
        { name: 'tree6', id: 6, parentId: 7, hidden: true },
        { name: 'tree8', id: 8, parentId: 3 },
      ],
      tree:null,
      lcout:3,//每行显示的数量
      formInline: {
        title: "",
      },
      columns: [{ field: 'ok3w_article_id', title: '上传文章主键id', type: 'guid', width: 110, hidden: true, require: true, align: 'left' },
      { field: 'ClassID', title: '分类', type: 'int', bind: { key: '下载分类', data: [] }, width: 80, require: true, align: 'left', sort: true },
      { field: 'SortPath', title: '目录短路径', type: 'string', width: 110, hidden: true, align: 'left' },
      { field: 'Title', title: '标题', type: 'string', width: 220, align: 'left' },
      { field: 'TitleColor', title: '文章颜色', type: 'string', width: 110, hidden: true, align: 'left' },
      { field: 'TitleURL', title: '文章路径', type: 'string', width: 110, hidden: true, align: 'left' },
      { field: 'AttachmentURL', title: '下载', type: 'file', width: 180, align: 'left' },
      { field: 'Content', title: '内容', type: 'string', width: 110, hidden: true, align: 'left' },
      { field: 'Author', title: '上传人', type: 'string', width: 120, hidden: true, align: 'left' },
      { field: 'ComeFrom', title: '上传来自于', type: 'string', width: 120, hidden: true, align: 'left' },
      { field: 'AddTime', title: '上传时间', type: 'datetime', width: 150, hidden: true, align: 'left', sort: true },
      { field: 'Inputer', title: '插入人', type: 'string', width: 120, hidden: true, align: 'left' },
      { field: 'IsPic', title: '图片列表', type: 'int', width: 110, hidden: true, align: 'left' },
      { field: 'PicFile', title: '文档图片', type: 'string', width: 220, hidden: true, align: 'left' },
      { field: 'IsPass', title: '是否审核', type: 'int', width: 110, hidden: true, align: 'left' },
      { field: 'IsTop', title: '是否置顶', type: 'int', width: 110, hidden: true, align: 'left' },
      { field: 'IsDelete', title: '是否删除', type: 'int', width: 110, hidden: true, align: 'left' },
      { field: 'IsCommend', title: '是否推荐', type: 'int', width: 110, hidden: true, align: 'left' },
      { field: 'IsMove', title: '是否滚动', type: 'int', width: 110, hidden: true, align: 'left' },
      { field: 'IsPlay', title: '是否轮播', type: 'int', width: 110, hidden: true, align: 'left' },
      { field: 'IsUserAdd', title: '上传人', type: 'int', width: 110, hidden: true, align: 'left' },
      { field: 'GiveJifen', title: '作者积分', type: 'int', width: 110, hidden: true, align: 'left' },
      { field: 'vUserGroupID', title: '游客权限', type: 'int', width: 110, hidden: true, align: 'left' },
      { field: 'vUserMore', title: '游客登记', type: 'int', width: 110, hidden: true, align: 'left' },
      { field: 'vUserJifen', title: '游客积分', type: 'int', width: 110, hidden: true, align: 'left' },
      { field: 'Hits', title: '查看数', type: 'int', width: 110, hidden: true, align: 'left' },
      { field: 'id', title: '文章id', type: 'int', width: 80, hidden: true, require: true, align: 'left' },
      { field: 'ChannelID', title: '栏目编号 1：软件管理栏，2：相关说明栏', hidden: true, type: 'int', width: 80, align: 'left' },
      { field: 'CreateID', title: '创建人id', type: 'int', width: 80, hidden: true, align: 'left' },
      { field: 'Creator', title: '创建人名称', type: 'string', width: 130, align: 'left' },
      { field: 'CreateDate', title: '创建时间', type: 'datetime', width: 150, align: 'left', sort: true },
      { field: 'ModifyID', title: '修改人id', type: 'int', width: 80, hidden: true, align: 'left' },
      { field: 'Modifier', title: '修改人名称', type: 'string', width: 130, align: 'left' },
      { field: 'ModifyDate', title: '修改时间', type: 'datetime', width: 150, align: 'left', sort: true }],
      logo: ref(imgUrl),
      fl_types: [
        { ok3w_article_id: 1, text: 'aaa1' },

      ],
      all_list:[],
      list: [
        { title: '框架2.x版本不支持直接升级Vue3版本(代码生成器已修改)' },

        //(框架内部组件vue2/3语法都在使用),你也可以使用vue3语法
      ],

    };
  },
  setup() {
    let open = (item) => {
      window.open(item.url, '_blank');
    };
    let interval;
    onMounted(() => {

    });
    onUnmounted(() => {
      interval && clearInterval(interval);

    });
    return { open };
  },
  mounted() {
    //console.log(Math.ceil(this.fl_types_1.length/3));
    let qid = "";
    var turl = "/api/Ok3w_Article/get_ok3w_for_front?qid=" + qid + "&lstype=all";
    http.post(turl, {}, true).then((s) => {
      this.fl_types = s.online_class_list;
      this.list = s.alltable;
      this.alllist = s.alltable;
      console.log(this.list);
      this.tree_source=s.tree_data;
      this.tree = this.base.convertTree(this.tree_source, (node, data, isRoot) => {
        //设定其他字段属性
        //node当前遍历的节点：{ name: 'tree1', id: 1, parentId: 0 }
        //data整个数据源
        //isRoot是否为根节点，一级节点

        //添加一些别的属性
        node.value = node.name;
        node.label = node.name;
        node.text = node.name;
        node.classid = node.classid;
      });
    });


  },
  methods: {
      rowClick({ row, column, event }) {
       this.open_info(row);
},
    nodeClick(node, selected){
       let params = {
        page: 1, //分页页数(可不填)
        rows: 30, //分页大小(可不填)
        sort: "title", //可不填
        order: "desc/asc", //可不填
        wheres:[
          { name: "ClassID", value: node.classid },
      /* { name: "ClassID", value: '30,31',displayType:"selectList" },  */
             ],  };
        this.$refs.tableList.load(params, true); //查询审核页的业务数据

    },

    open_info(item){
        console.log("item")
        this.$nextTick(()=>{
        this.http.post("/api/Ok3w_Article/get_ok3w_for_front?qid=" + item.ok3w_article_id + "&lstype=",{},true).then(result=>{
                    console.log(result.alltable);
                    
                    this.$refs.look_downfile.fields=result.alltable[0].q
                   // console.log(this.$refs.look_downfile.fields);
                    this.$refs.look_downfile.dialogVisible=true;
                    this.$refs.look_downfile.get_fujian_path();
        })
      })
    },
    onSubmit() {
      
      let params = {
        page: 1, //分页页数(可不填)
        rows: 30, //分页大小(可不填)
        sort: "title", //可不填
        order: "desc/asc", //可不填
        wheres:[{ name: "Title", value: this.formInline.title,displayType:"like" },
             ],  
    };
   // params.value="out";//说明从系统外登录
    this.$refs.tableList.load(params, true); //查询审核页的业务数据
  },

  },
  destroyed() {
  }
};

</script>
<style>
.el-row {
  margin-bottom: 10px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 30px;
}
.row-bg {
  padding: 5px 0;
  background-color: #f9fafc;
}
.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}

.box-card {
  width: 350px;
}
</style>
<style lang="less" scoped>
.role-container {
  position: absolute;
  background: #f6f6f6;
  height: 100%;
  width: 100%;
  padding: 10px;
  display: flex;
  .flex-col {
    display: flex;
    flex-direction: column;
  }
  .role-tree-left {
    border: 1px solid #f2f2f2;
    background: #fff;
    width: 230px;
    margin-right: 10px;
    .title {
      i {
        margin-left: 10px;
      }
    }
  }
  .role-tree-right {
    background: #fff;
    border: 1px solid #f2f2f2;
    width: 0;
    flex: 1;
    .title {
      display: flex;
      i {
        margin-left: 10px;
      }
      div {
        flex: 1;
      }
    }
    .action-group {
      display: flex;
      // line-height: 32px;
      justify-content: center;
      align-items: center;
      label {
        float: left;
      }
      .action-text {
        line-height: 33px;
        label {
          margin-right: 5px;
        }
      }
    }
  }
  .title {
    padding: 10px;
    background: rgb(246 250 255);
    font-weight: bold;
    font-size: 14px;
    letter-spacing: 2px;
  }
  .el-role-list {
    flex: 1;
    height: 0;
    overflow-x: hidden;
  }
}
.role-tree-left ::v-deep(.el-tree-node__content) {
  cursor: pointer;
  height: auto;
  padding: 5px;
  margin: 2px 10px;
  font-size: 15px;
}
.role-tree-left ::v-deep(.el-tree-node__content:hover) {
  background: #f4f4f4;
  border-radius: 20px;
}
.role-tree-left ::v-deep(.is-current > .el-tree-node__content:first-child) {
  background: #f2f2f2;
  border-radius: 20px;
}
.role-tree-right ::v-deep(.el-tree-node__content) {
  margin-bottom: 5px;
  height: auto;
}
.role-tree-right ::v-deep(.el-checkbox__label) {
  position: relative;
  top: 2px;
}
</style>
